<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Babylon.js Demo</title>
    <script src="https://cdn.babylonjs.com/babylon.js"></script>
    <style>
        canvas {
            width: 100%;
            height: 100vh;
        }
    </style>
</head>
<body>
<canvas id="renderCanvas"></canvas>
<script>
    var canvas = document.getElementById("renderCanvas");
    var engine = new BABYLON.Engine(canvas, true);

    var scene = new BABYLON.Scene(engine);

    // var camera = new BABYLON.FreeCamera("camera", new BABYLON.Vector3(0, 5, -10), scene);
    var camera = new BABYLON.ArcRotateCamera("camera", 0, Math.PI / 4, 10, BABYLON.Vector3.Zero(), scene);
    // camera.setTarget(BABYLON.Vector3.Zero());
    camera.attachControl(canvas, true);

    var box = BABYLON.MeshBuilder.CreateBox("box", {size: 2}, scene);
    var isBig = false
    box.actionManager = new BABYLON.ActionManager(scene);
    box.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, function () {

        if (isBig) {
            box.scaling = new BABYLON.Vector3(1, 1, 1); // 缩小回原大小
        } else {
            box.scaling = new BABYLON.Vector3(2, 2, 2); // 放大两倍
        }

        isBig = !isBig; // 切换状态
    }));

    engine.runRenderLoop(function () {
        scene.render();
    });


</script>
</body>
</html>
